<template>
	<view class="" style="padding: 20rpx;">
		<view style="font-size: 24rpx;color: #e3e3e3;text-align: center;">共{{single.status == 2?'1':'0'}}张发票，含1个订单
		</view>
		<view class="single">
			<view>发票类型: 电子发票</view>
			<view>开票状态：{{single.status==0?'已申请':'已处理'}}</view>
			<view>
				发票金额: {{single.price}}
			</view>
			<view class="">
				抬头类型: {{single.type==1?'个人/非企业单位':'企业'}}
			</view>
			<view class="">
				申请时间: {{data(single.createtime)}}
			</view>
			<view class="">
				邮箱地址: {{single.email}}
			</view>

		</view>
		<view v-if="single.status == 2" style="font-size: 24rpx;color: blue;" @click="click">点击查看电子发票</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				single: {}
			}
		},
		async onLoad({
			id
		}) {
			let res = await this.$api.getmyfp({})
			console.log(res);
			this.single = res.data.data.filter(v => {
				return v.id == id
			})[0]

		},
		methods: {
			data(v) {
				console.log(v);
				let date = new Date(parseInt(v * 1000))
				console.log(date);
				// let date = new Date(parseInt(timestamp) * 1000)
				let Year = date.getFullYear()
				let Moth =
					date.getMonth() + 1 < 10 ?
					"0" + (date.getMonth() + 1) :
					date.getMonth() + 1
				let Day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate()
				let Hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
				let Minute =
					date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
				let Sechond =
					date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()
				let GMT =
					Year +
					"-" +
					Moth +
					"-" +
					Day +
					"   " +
					Hour +
					":" +
					Minute +
					":" +
					Sechond
				return GMT
			},
			change(e) {
				console.log('change', e);
			},
			click() {
				console.log(this.single.image);
				uni.previewImage({
					urls: [this.single.image]
				})
			}
		}
	}
</script>

<style lang="scss">
	page {

		background-color: transparent;
	}

	.single {
		font-size: 24rpx;
		line-height: 60rpx;
		color: #3e3e3e;

		view {
			padding: 20rpx 20rpx 10rpx;
			// padding-bottom: 10rpx;
			border-bottom: 2rpx solid #e3e3e3;
		}
	}
</style>